package com.chenglu.android.goodsinfo.adapter;

import android.content.Context;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.chenglu.android.R;
import com.chenglu.android.goodsinfo.bean.GoodsInfoBean;
import com.chenglu.android.goodsinfo.bean.SpecBean;

import java.util.List;

;

/**
 * @author: lyj
 * @Created: by Copyright 2023/3/13 Guangzhou Hongma Technology Co., Ltd. All rights reserved.
 * @Description：首页详情流式选择
 */
public class ShopFlowItemAdapter extends BaseQuickAdapter<GoodsInfoBean.Data.GoodsSpecs.SpecValue, BaseViewHolder> {

    private Context infoActivity;


    public ShopFlowItemAdapter(@Nullable Context context, List<GoodsInfoBean.Data.GoodsSpecs.SpecValue> data) {
        super(R.layout.item_shop_item_flow_, data);
        this.infoActivity = context;
    }


    @Override
    protected void convert(@NonNull BaseViewHolder helper, GoodsInfoBean.Data.GoodsSpecs.SpecValue item) {

        if (item == null) {
            return;
        }
        TextView textView = helper.getView(R.id.tv_item_shop_flow_name);
        textView.setText(item.getValue());

        if (helper.getAdapterPosition() == getthisPosition()) {
            textView.setBackground(infoActivity.getResources().getDrawable(R.drawable.solid_home_color_shape_4));
            textView.setTextColor(infoActivity.getResources().getColor(R.color.white));

        } else {
            textView.setTextColor(infoActivity.getResources().getColor(R.color.color_999999));
            textView.setBackground(infoActivity.getResources().getDrawable(R.drawable.solid_home_detail_shape_4));
        }


    }

    //先声明一个int成员变量,若为0默认显示第一个
    private int thisPosition = 0;

    //再定义一个int类型的返回值方法
    public int getthisPosition() {
        return thisPosition;
    }

    //   传入点击的位置
    public void setThisPosition(int thisPosition) {
        this.thisPosition = thisPosition;
        notifyDataSetChanged();
    }



}
